﻿@using PageAdmin.Utils
@{
    dynamic permissionsSet = ViewBag.PermissionsSet;
    CurrentUser user = ViewBag.CurrentUser;
    int tableId = ViewBag.TableId;
    string table = ViewBag.Table;
    string action = ViewContext.RouteData.Values["action"].ToString();
    IEnumerable<dynamic> fieldData = Html.GetFieldList((string)ViewBag.Table, action, user);
    var guid = Html.Guid();
}
<script src="~/Incs/UEditor/ueditor.forAdmin.config.js" type="text/javascript"></script>
<script src="~/Incs/UEditor/ueditor.all.min.js" type="text/javascript"></script>
<div class="main">
    <form method="post" id="_form" class="form  ui-validForm" data-validate-params="beforeSubmit:'BeforeSubmit'" data-source="@Model">
        <div class="tabcontent" data-tab-params="tabName:'基本信息'">
            <div class="form-group" id="_ColumnIdBox">
                <label class="control-label">所属栏目*</label>
                <div class="controls form-inline">
                    <select class="form-control" style="width:auto;" name="ColumnId" id="ColumnId" data-validate="dataType:'*',nullMsg:'请选择栏目!',errorMsg:'请选择栏目',ignoreParentHidden:true" data-custom-params="valueField:'Id',textField:'Name',isTree:true,linkage:true" data-source="@Html.GetColumnListJsonByUser(tableId,user)">
                        <option value="">请选择栏目...</option>
                    </select>
                    <span class="help-block"></span>
                </div>
                <script type="text/javascript">
                    var $columnId = $("#ColumnId");
                    $columnId.SelectBind({ dataSourceFrom: "attr" }); //绑定栏目数据
                    var columnDataSource = $columnId.attr("data-source");
                    if (columnDataSource == "[]" || columnDataSource == "") {
                        $("#_ColumnIdBox").hide();
                    }
                </script>
            </div>
            @{
            string beforeSubmitJs = "";
            var data = new ViewDataDictionary();
            data.Add("from", "admin");
            data.Add("currentUser", user);
            data.Add("guid", guid);
            data.Add("i", 0);
            int i = 0;
            if (fieldData != null)
            {
                foreach (var row in fieldData)
                {
                    data["i"] = i;
                    beforeSubmitJs += row.BeforeSubmitJs;
                    Html.RenderPartial("~/Areas/E/Views/CustomForm/FormPartial.cshtml", (object)row, data);
                    i++;
                }
            }

            }

            <div class="form-group" id="_box_is_draft">
                <label class="control-label">信息状态</label>
                <div class="controls">
                    <label class="radio-inline">
                        <input name="State" id="State" value="1" type="radio" checked />已审
                    </label>
                    <label class="radio-inline">
                        <input name="State" id="State" value="0" type="radio" />待审
                    </label>
                    <label class="radio-inline">
                        <input name="State" id="State" value="-1" type="radio" />退稿
                    </label>
                    <label class="radio-inline">
                        <input name="State" id="State" value="-2" type="radio" />草稿
                    </label>
                    <span class="help-block"></span>
                </div>
            </div>

        </div>


        <div class="tabcontent" data-tab-params="tabName:'其他属性'">
            <div class="box_seo_set" data-source="@ViewBag.SeoSet">
                <div class="form-group">
                    <label class="control-label">seo标题</label>
                    <div class="controls">
                        <input name="seo_set_Title" id="seo_set_Title" type="text" maxlength="50" class="form-control">
                        <span class="help-block"></span>
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label">seo关键词</label>
                    <div class="controls">
                        <input name="seo_set_Keywords" id="seo_set_Keywords" type="text" maxlength="150" class="form-control">
                        <span class="help-block"></span>
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label">seo描述</label>
                    <div class="controls">
                        <textarea id="seo_set_Description" name="seo_set_Description" class="form-control" style="height:60px;"></textarea>
                        <span class="help-block"></span>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="control-label">Tag标签</label>
                <div class="controls">
                    <div class="input-group">
                        <input name="tag_set_tags" id="tag_set_tags" type="text" class="form-control" value="@ViewBag.Tags">
                        <input name="_tag_set_tags" type="hidden" value="@ViewBag.Tags">
                        <span class="input-group-btn">
                            <button type="button" class="btn btn-default ui-dialog" data-custom-params="title:'选择标签',url:'@Url.ActionUrl("Select", "Tag")?tableId=@tableId&objname=#tag_set_tags',width:'700px',height:'95%',target:'self'">选择标签</button>
                        </span>
                    </div>
                    <span class="help-block">多个标签用逗号隔开，如A,B,C</span>
                </div>
            </div>
            <div class="form-group">
                <label class="control-label">信息属性</label>
                <div class="controls form-inline">
                    <select name="IsGood" id="IsGood" class="form-control" style="width:auto">
                        <option value="0">推荐属性</option>
                        <option value="1">1级推荐</option>
                        <option value="2">2级推荐</option>
                        <option value="3">3级推荐</option>
                        <option value="4">4级推荐</option>
                        <option value="5">5级推荐</option>
                        <option value="6">6级推荐</option>
                        <option value="7">7级推荐</option>
                        <option value="8">8级推荐</option>
                        <option value="9">9级推荐</option>
                        <option value="10">10级推荐</option>
                    </select>
                    <select name="IsHot" id="IsHot" class="form-control" style="width:auto">
                        <option value="0">热门属性</option>
                        <option value="1">1级热门</option>
                        <option value="2">2级热门</option>
                        <option value="3">3级热门</option>
                        <option value="4">4级热门</option>
                        <option value="5">5级热门</option>
                        <option value="6">6级热门</option>
                        <option value="7">7级热门</option>
                        <option value="8">8级热门</option>
                        <option value="9">9级热门</option>
                        <option value="10">10级热门</option>
                    </select>
                    <select name="IsTop" id="IsTop" class="form-control" style="width:auto">
                        <option value="0">置顶属性</option>
                        <option value="1">1级置顶</option>
                        <option value="2">2级置顶</option>
                        <option value="3">3级置顶</option>
                        <option value="4">4级置顶</option>
                        <option value="5">5级置顶</option>
                        <option value="6">6级置顶</option>
                        <option value="7">7级置顶</option>
                        <option value="8">8级置顶</option>
                        <option value="9">9级置顶</option>
                        <option value="10">10级置顶</option>
                    </select>
                    <span class="help-block">属性可用于前台数据筛选和组合，字段名分别为：isGood，isHot，isTop，都是数值类型</span>
                </div>
            </div>
            <div class="form-group">
                <label class="control-label">点击数</label>
                <div class="controls form-inline">
                    <input type="text" value="0" name="Clicks" id="Clicks" data-validate="dataType:'numeric'" class="form-control form-control-xs" />
                    <span class="help-block"></span>
                </div>
            </div>

            <div class="form-group">
                <label class="control-label">预上线日期</label>
                <div class="controls form-inline">
                    <input type="text" name="_OnlineDate" id="_OnlineDate" class="form-control laydate-icon" value="@ViewBag.OnlineDate" onclick="laydate({istime: true,format:'YYYY-MM-DD hh:mm:ss'})" />
                    <span class="help-block">预上线日期大于当前时间后自动上线（isOnline字段值更新为1），不填写则信息默认为上线状态。</span>
                </div>
            </div>

            <div class="form-group">
                <label class="control-label">到期日期</label>
                <div class="controls form-inline">
                    <input type="text" name="_ExpireDate" id="_ExpireDate" class="form-control laydate-icon" value="@ViewBag.ExpireDate" onclick="laydate({istime: true,format:'YYYY-MM-DD hh:mm:ss'})" />
                    <span class="help-block">当前日期大于所设置的过期日期后，信息将自动到期（isExpire字段值更新为1），不填写则不进行任何处理。</span>
                </div>
            </div>

            <div class="form-group template_set_box" data-source="@ViewBag.TemplateSet">
                <label class="control-label">信息页模版</label>
                <div class="controls form-inline">
                    <div class="input-group">
                        <input type="text" placeholder="信息页模板文件" maxlength="100" id="template_set_TemplateDetail" name="template_set_TemplateDetail" class="form-control form-control-sm" />
                        <span class="input-group-btn">
                            <button type="button" class="btn btn-default ui-dialog" data-custom-params="title:'选择信息页模板',url:'@Url.ActionUrl("Select", "TemplateManager")?objname=#template_set_TemplateDetail',width:'650px',height:'95%',target:'self'">选择</button>
                        </span>
                    </div>
                    <span class="help-block">不填写则继承栏目设置中的内容页模板</span>
                </div>
            </div>

            <div class="url_set_box" data-source="@ViewBag.UrlSet">
                <div class="form-group">
                    <label class="control-label">自定义文件名</label>
                    <div class="controls">
                        <input name="url_set_ZdyPath" id="url_set_ZdyPath" type="text" maxlength="50" class="form-control form-control-sm" data-validate="dataType:'string',ignoreEmpty:true,errorMsg:'只能填写英文和数字组成的字符！'">
                        <span class="help-block">不能填写纯数字，留空则采用Id作为文件名。</span>
                    </div>
                </div>

                <div class="form-group">
                    <label class="control-label">自定义链接</label>
                    <div class="controls">
                        <input name="url_set_ZdyUrl" id="url_set_ZdyUrl" type="text" maxlength="150" class="form-control form-control-sm">
                        <span class="help-block">留空则系统默认</span>
                    </div>
                </div>
            </div>

            @*<div class="form-group">
                <label class="control-label">评论数</label>
                <div class="controls form-inline">
                    <input type="text" value="0" name="comments" id="comments" class="form-control form-control-xs" />
                    <span class="help-block"></span>
                </div>
            </div>*@
            @*<div class="form-group" id="_commentSetBox">
                <label class="control-label">评论功能</label>
                <div class="controls">
                    <label class="checkbox-inline">
                        <input class="ui-show-hide" name="comment_set_inherit" id="comment_set_inherit" value="1" type="checkbox" hideObjs=".box_comment_set" checked>继承栏目设置
                    </label>
                    <span class="box_comment_set">
                        &nbsp; <label class="checkbox-inline">
                            <input name="comment_set_open" id="comment_set_open" value="1" type="checkbox">开启评论
                        </label>
                        <label class="checkbox-inline">
                            <input name="comment_set_need_member" id="comment_set_need_member" value="1" type="checkbox">只允许会员评论
                        </label>
                        <label class="checkbox-inline">
                            <input name="comment_set_default_state" id="comment_set_default_state" value="0" type="checkbox" checked>评论需要审核
                        </label>
                    </span>
                    <span class="help-block"></span>
                </div>
            </div>*@
            <script type="text/javascript">
                //内容模板数据绑定
                $(".template_set_box").FormBind({ fieldPrefix: "template_set_", dataSourceFrom: "attr" });
                //seo数据绑定
                $(".box_seo_set").FormBind({ fieldPrefix: "seo_set_", dataSourceFrom: "attr" });
                //seo数据绑定
                $(".url_set_box").FormBind({ fieldPrefix: "url_set_", dataSourceFrom: "attr" });

                ////评论数据绑定
                //$(".box_comment_set").FormBind({fieldPrefix:"comment_set_",dataSourceForm:"attr"});
                //if(!$.isEmptyObject(commentSet))
                //{
                //    $("#comment_set_inherit").click();
                //}
            </script>
        </div>

        <div class="submit-footerbar">
            <label class="control-label"></label>
                <div class="controls">
                    <input type="hidden" name="Guid" id="Guid" value="@guid" />
                    <input type="hidden" name="Id" id="Id" value="@ViewBag.DetailId" />
                    <button type="button" class="btn btn-primary ui-pagePost" data-custom-params="url:'@Url.ActionUrl()',callBack:'CallBack'">提交</button>
                    <button type="button" class="btn btn-default ui-closeDialog">关闭</button>
                </div>
            </div>
    </form>
</div>


<script type="text/javascript">
    $(".tabcontent").InitTab();
    function BeforeSubmit() {
    @Html.Raw(beforeSubmitJs)
        return true;
    }
    var id = Request("id");
    if (id != "") {
        $("#_form").FormBind({ dataSourceFrom: "attr" });
    }
    else
    {
        var columnId = GetLocalStorage("columnId");
        if (columnId != "")
        {
            $("#_ColumnIdBox").FormBind({}, { "ColumnId":columnId });
        }
    }

    function CallBack()
    {
        var $columnId = $("#ColumnId");
        var columnId = $columnId.val();
        SetLocalStorage("columnId", columnId);
        PostRefreshBack();
    }
</script>
